import { defineStore } from 'pinia'
export const useSearchHistry = defineStore('searchHistry', {
  persist: true,
  state: (): {
    list: string[]
  } => {
    return {
      list: []
    }
  },
  getters: {},
  actions: {
    addSearch(v: string) {
      if (this.list.indexOf(v) != -1) {
        this.list.splice(this.list.indexOf(v), 1)
      }
      this.list = [v].concat(this.list).slice(0, 10)
    },
    clearSearch() {
      this.list = []
    }
  }
})
